from selenium.webdriver.common.by import By
from pages.base_page import Page


class PostChatSurveyPage(Page):
    ele_title = (By.ID, u'page-postChatSurvey-title')
    ele_campaign_select = (By.XPATH, u'(//div[@role="button" and contains(@class,"MuiInputBase-input")])[2]')
    ele_time_range = (By.XPATH, u'(//div[contains(@class,"MuiInputBase-input")])[1]')

    # 无此feature的图片
    ele_no_post_chat_survey_image = (By.XPATH, u'//h3[text()="Feature Introduction"]//../div/img')
    ele_unlock_this_feature = (By.XPATH, u'//button/span[text()="Unlock This Feature"]')

    def __init__(self, driver, url, site_id):
        Page.__init__(self, driver, url)
        self.site_id = site_id
        self.url = url

    def postchat_survey_page_eles_check_when_has_postchat_survey_feature(self):
        self.find_element(*self.ele_title).is_enabled()
        self.find_element(*self.ele_campaign_select).is_enabled()
        self.find_element(*self.ele_time_range).is_enabled()

    def postchat_survey_page_eles_check_when_no_postchat_survey_feature(self):
        self.find_element(*self.ele_title).is_enabled()
        self.find_element(*self.ele_no_post_chat_survey_image).is_enabled()
        self.find_element(*self.ele_unlock_this_feature).is_enabled()
